var checkPhone = (value, callback) => {
    const phoneReg = /^1[3|4|5|7|8][0-9]{9}$/
    if (!value) {
        return callback(new Error('手机号码不能为空'))
    }
    setTimeout(() => {
        if (!Number.isInteger(+value)) {
            callback(new Error('请输入数字值'))
        } else {
            if (phoneReg.test(value)) {
                callback()
            } else {
                callback(new Error('手机号码格式不正确'))
            }
        }
    }, 100)
};
const Method={
    formatDate:function(cellValue) {
        if(cellValue==null || cellValue=="") return "";
        let date = new Date(parseInt(cellValue));
        let Y = date.getFullYear() + '-';
        let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
        let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
        let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
        let m = date.getMinutes()  < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
        let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
        return Y + M + D ;
    },
    formatTime:function(cellValue) {
        if(cellValue==null || cellValue=="") return "";
        let date = new Date(parseInt(cellValue));
        let Y = date.getFullYear() + '-';
        let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
        let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
        let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
        let m = date.getMinutes()  < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
        let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
        return Y + M + D +h+m+s;
    },
    checkPhone:checkPhone,
    getParmFormUrl:function(url){
        var restData = new Object(); 
        if ( url.indexOf( "?" ) != -1 ){
        var str = url.split( "?" ); 
        var strs=str[1].split("&");
        for ( var i = 0; i < strs.length; i++ ) {  
                restData[ strs[ i ].split( "=" )[ 0 ] ] = ( strs[ i ].split( "=" )[ 1 ] );  
            } 
        }
        return restData; 
    }
}

export default Method;